home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / blankery / blanker / source / blankers / interference / blank.c next >
C/C++ Source or Header  |  1993-08-15  |  3KB  |  77 lines

  1. #include <exec/types.h>
  2. #include <intuition/intuition.h>
  3. #include <dos/dos.h>
  4.  
  5. #include <clib/exec_protos.h>
  6. #include <clib/intuition_protos.h>
  7. #include <clib/graphics_protos.h>
  8. #include <clib/alib_protos.h>
  9.  
  10. #include "/defs.h"
  11.  
  12. extern    ULONG    Depth, Mode;
  13.  
  14. UWORD    Colors5[] = {    0x0F20, 0x0E30, 0x0C50, 0x0B60, 0x0980, 0x0890, 0x06B0, 0x05C0, 0x03E0, 0x02F0, 0x00F2,
  15.     0x00E3, 0x00C5, 0x00B6, 0x0098, 0x006B, 0x005C, 0x003E, 0x002F, 0x020F, 0x030E, 0x050C,    0x060B, 0x0809,
  16.     0x0908, 0x0B06, 0x0C05, 0x0E03, 0x0F02, 0x0F00 }, Colors4[] = {    0x0E03, 0x0B06, 0x0909, 0x060B, 0x030E,
  17.     0x003E, 0x006B, 0x0099, 0x00B6, 0x00E3, 0x03E0,    0x06B0, 0x0990, 0x0B60, 0x0E30 }, Colors3[] = {    0x0E00,
  18.     0x0770, 0x00E0, 0x0077, 0x000E, 0x0707 }, Colors2[] = {    0x0E00, 0x00E0, 0x000E }, Colors1[] = { 0x0FFF },
  19.     *Table[5];
  20.  
  21. VOID CycleColors( struct Screen *Scr, ULONG Depth )
  22. {
  23. static    ULONG    pos = 0;
  24.     ULONG    i, j = 0, Colors = ( 1L << Depth ) - 1;
  25.  
  26.     SetRGB4(&( Scr->ViewPort ), 0, 0, 0, 0 );
  27.     for( i = pos; j < Colors; i = ++i % Colors )
  28.         SetRGB4(&( Scr->ViewPort ), ++j, ( Table[Depth-1][i] & 0x0F00 ) >> 8,
  29.             ( Table[Depth-1][i] & 0x00F0 ) >> 4, Table[Depth-1][i] & 0x000F);
  30.  
  31.     pos = ++pos % Colors;
  32. }
  33.  
  34. VOID Interference( struct Screen *Scr )
  35. {
  36.     LONG    x, y, factor, mod = ( 1L << Depth ) - 1;
  37.     WORD    Wid = Scr->Width, Hei = Scr->Height;
  38.  
  39.     ScreenToFront( Scr );
  40.  
  41.     factor = RangeRand( 20 ) + 1;
  42.     for( y = -Hei / 2 + 1; ( y <= 0 ) && (!( SetSignal( 0L, 0L ) & SIGBREAKF_CTRL_C )); y++ ) {
  43.         for( x = -Wid / 2 + 1; x <= 0; x++ ) {
  44.             SetAPen( &( Scr->RastPort ), (UBYTE)(((( x * x + y * y ) / factor ) % mod ) + 1 ));
  45.             WritePixel( &( Scr->RastPort ), (SHORT)( Wid / 2 - 1 + x ), (SHORT)( Hei / 2 - 1 + y ));
  46.             WritePixel( &( Scr->RastPort ), (SHORT)( Wid / 2 - 1 - x ), (SHORT)( Hei / 2 - 1 + y ));
  47.             WritePixel( &( Scr->RastPort ), (SHORT)( Wid / 2 - 1 + x ), (SHORT)( Hei / 2 - 1 - y ));
  48.             WritePixel( &( Scr->RastPort ), (SHORT)( Wid / 2 - 1 - x ), (SHORT)( Hei / 2 - 1 - y ));
  49.         }
  50.     }
  51.  
  52.     for( x = 0; x < 400 && (!( SetSignal( 0L, 0L ) & SIGBREAKF_CTRL_C )); x++ ) {
  53.         WaitTOF();
  54.         CycleColors( Scr, Depth );
  55.     }
  56. }
  57.  
  58. VOID blank( VOID )
  59. {
  60.     struct Screen *Scr;
  61.  
  62.     if( Scr = OpenScreenTags( NULL, SA_Depth, Depth, SA_Overscan, OSCAN_STANDARD, SA_DisplayID, Mode, SA_Quiet,
  63.         TRUE, SA_Behind, TRUE, TAG_DONE )) {
  64.  
  65.         Table[0] = Colors1; Table[1] = Colors2; Table[2] = Colors3; Table[3] = Colors4; Table[4] = Colors5;
  66.         CycleColors( Scr, Depth );
  67.         SetRast(&( Scr->RastPort ), 0 );
  68.         BlankMousePointer();
  69.  
  70.         while(!( SetSignal( 0L, 0L ) & SIGBREAKF_CTRL_C )) Interference( Scr );
  71.  
  72.         SetSignal( 0L, SIGBREAKF_CTRL_C );
  73.         UnblankMousePointer();
  74.         CloseScreen( Scr );
  75.     }
  76. }
  77.